import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ty_smart_watch/common/images_url.dart';
import 'package:ty_smart_watch/page/sport/controller/sport_controller.dart';
import 'package:ty_smart_watch/page/sport/sport_detail_first/data_list.dart';
import 'package:ty_smart_watch/page/sport/sport_detail_first/data_grid.dart';
import 'package:ty_smart_watch/page/sport/sport_detail_first/sport_main_image.dart';
import 'package:ty_smart_watch/utils/Log.dart';

class SportDetailFirstPage extends StatefulWidget {
  const SportDetailFirstPage({super.key});

  @override
  State<SportDetailFirstPage> createState() => _SportDetailFirstPageState();
}

class _SportDetailFirstPageState extends State<SportDetailFirstPage> {
  int _id = 0;
  SportController sportController = Get.find();

  @override
  void initState() {
    super.initState();
    _id = Get.arguments["id"];
    Log.d("init id : $_id");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: Text(sportController.sportList.value[_id].title),
          leading: IconButton(
            icon: const Icon(Icons.arrow_back_ios),
            onPressed: () {
              Get.back();
            },
          ),
        ),
        body: Container(
          color: Colors.white,
          child: Column(
            children: [
              SportMainImage(id: _id),
              Container(
                color: Colors.white,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(
                      "0",
                      style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
                    ),
                    SizedBox(width: 6),
                    Text(
                      "公里",
                      style: TextStyle(fontSize: 10),
                    ),
                  ],
                ),
              ),
              Container(
                color: Colors.white,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Image.asset(ICON_CHILD_DISTANCE, width: 16, height: 16),
                    Text(
                      "${sportController.sportList.value[_id].title}总里程",
                      style: TextStyle(fontSize: 8),
                    ),
                  ],
                ),
              ),
              DataGrid(),
              DataList(
                id: _id,
              ),
            ],
          ),
        ));
  }
}
